<?php

namespace app\model\setting\admin;

use app\model\BaseModel;
use think\facade\App;

/**
 * 后台用户表
 */
class SystemUser extends BaseModel
{

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 模型名称
     * @var string
     */
    protected $table = 'free_auth_user';

    // 设置字段信息
    protected $type = [
        'status' => 'boolean',
    ];

    /**
     * 用户与角色多对多关联
     * @return \think\model\relation\BelongsToMany
     */
    public function roles()
    {
        return $this->belongsToMany(SystemRole::class, SystemGroupAccess::class, 'group_id', 'uid');
    }

    public function searchAccountAttr($query, $value)
    {
         $query->where('account', 'like', '%' . $value . '%');
    }


}